#include "common.h"

#include <signal.h>

int func1(int *p)
{
	*p = 1;
	return *p;//segment default
}

int func2(int *p)
{
	func1(p);
	return 0;
}

int func3(int *p)
{
	func2(p);
	return 0;
}

void signal_handler(int signum)
{
	printf("rev Signum : %d\n", signum);
	exit(0);
}

int main()
{
	struct sigaction act;

	act.sa_handler = signal_handler;

	sigemptyset(&act.sa_mask);
	sigaddset(&act.sa_mask, SIGSEGV);

	act.sa_flags = 0;

	sigaction(SIGSEGV, &act, NULL);

	int i = 0;
	while(i++ < 3)
	{
		sleep(1);
		printf("delay 1s\n");
	}

	int *p = NULL;
	func3(p);
	return 0;
}
